package com.dy.course.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dy.course.mapper.UserMapper;
import com.dy.course.service.INameService;

@Service
public class NameService implements INameService {

	@Autowired
	private UserMapper mapper;

	@Override
	public String getValueById(Long id, String tableName, String columnName) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("tableName", tableName);
		params.put("id", id);
		params.put("keyName", columnName);
		return mapper.selectValueById(params);
	}

	@Override
	public String getDepartmentName(Long id) {
		return getValueById(id,"department","name");
	}

	@Override
	public String getUserName(Long id) {
		return getValueById(id,"user","name");
	}

	@Override
	public String getUrlName(Long id) {
		return getValueById(id,"resource","url");
	}

	@Override
	public String getRoomName(Long id) {
		return getValueById(id,"room","name");
	}

	@Override
	public String getMac(Long id) {
		return getValueById(id,"room","mck");
	}


}
